from flask import Flask

from App.middleware import init_middleware
from App.plugins import init_plugins
from App.settings import envs

from App.views import init_view


def create_app(env):
    app = Flask(__name__)  # 主程序

    app.config.from_object(envs.get(env))  # 配置环境变量

    init_view(app=app)  # 初始化路由在views/__init__中

    init_plugins(app=app)  # 第三方插件

    init_middleware(app=app)

    return app
